/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.funmodelling;

/**
 *
 * @author Mustafa Tosun
 */
public class Vertex implements Comparable<Vertex> {

    public float X;
    public float Y;
    public float Z;
    public int Id;

    public Vertex() {
        X = 0.0f;
        Y = 0.0f;
        Z = 0.0f;
    }
    public Vertex(int id) {
        X = 0.0f;
        Y = 0.0f;
        Z = 0.0f;
        Id = id;
    }

    public Vertex(float x, float y, float z) {
        X = x;
        Y = y;
        Z = z;
    }

    @Override
    public String toString() {
        return "<[Id:" + Id + "]\t" + Float.toString(X) + " : " + Float.toString(Y) + " : " + Float.toString(Z) + " > ";
    }

    public int compareTo(Vertex v) {

        if(Id != v.Id)
            return 0;

        if (X == v.X && Y == v.Y && Z == v.Z) {
            return 1;
        } else {
            return 0;
        }
    }

    @Override
    @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
    public boolean equals(Object o){

        Vertex v = (Vertex) o;
        if(o == null)
            return false;
        
        if(v.Id == Id)
            return true;
        else
            if(v.X == X && v.Y == Y && v.Z == Z)
                return true;
            else
                return false;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 67 * hash + Float.floatToIntBits(this.X);
        hash = 67 * hash + Float.floatToIntBits(this.Y);
        hash = 67 * hash + Float.floatToIntBits(this.Z);
        hash = 67 * hash + this.Id;
        return hash;
    }
}
